package com.mcf.xiaolinju.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mcf.xiaolinju.vo.noticeReturn;
import com.mcf.xiaolinju.entity.Notices;
import com.mcf.xiaolinju.service.impl.NoticesServiceImpl;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mcf
 * @since 2021-12-02
 */
@CrossOrigin
@RestController
@RequestMapping("/xiaolinju/notices")
public class NoticesController {
    @Resource
    NoticesServiceImpl noticesService;
    //公告添加
    @RequestMapping("/add")
    public String add( int noticestype,String title,String notice,String starttime,String endtime,int villageid,int createid){
        return noticesService.add(noticestype,title,notice,starttime,endtime,villageid,createid);
    }
    //公告修改
    @RequestMapping("/update")
    public String update(int id, String title, String notice, String starttime, String endtime, int userid){
           return  noticesService.update(id,title,notice,starttime,endtime,userid);
    }
    //公告删除
    @RequestMapping("/del")
    public String del(int id,int userid){
         return noticesService.del(id,userid);
    }
    //公告的撤回
    @RequestMapping("/undo")
    public String undo(int id,int userid){
        return noticesService.undo(id,userid);
    }
    //批量的撤回
    @RequestMapping("/manyundo")
    public String manyundo(Integer[] id,int updateid){
        return noticesService.manyundo(id,updateid);
    }
    //批量删除
    @RequestMapping("/manydel")
    public String manydel(Integer[] id,int updateid){
        return noticesService.manydel(id,updateid);
    }
    //公告模糊查询
    @RequestMapping("/selectdim")
    public Page<noticeReturn> selectdim(int pageSize, int pageNo, int id,int type,String title,String time){

        return noticesService.selectdim(new Page<noticeReturn>(pageNo,pageSize),id,type,title,time);
    }
    //公告的分页查询
    @RequestMapping("/selectpage")
    public Page<noticeReturn> selectpage(int pageSize, int pageNo, int id,int type){
       return noticesService.selectpage(new Page<noticeReturn>(pageNo,pageSize),id,type);
    }
    //主键查询
    @RequestMapping("/getById")
    public Notices getById(int id){
        return  noticesService.getById(id);
    }
    //小程序查询当天的公告
    @RequestMapping("/selectnotice")
    public List<Notices> selectnotice(int id){
        return noticesService.selectnotice(id);
    }
    //小程序模糊查询小区的公告
    @RequestMapping("/selectdimnotice")
    public List<Notices> selectdimnotice(int id, String noticeid, String date, String title){
        System.out.println("start");
        System.out.println(id);
        System.out.println(noticeid);

        System.out.println(date);
        System.out.println(title);
        System.out.println("end");

        return  noticesService.selectdimnotice(id,noticeid,date,title);
    }


}
